<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>

    class Person {
      //构造函数
      constructor(name, age) {
        this.name = name;
        this.age = age;
      }

      //定义方法
      running() {
        console.log(this.name, this.age, "running");
      }

    }
    const p = new Person("why", 18);
    console.log(p.name, p.age);
    p.running();

    let func = p.running;
    // func();

    var obj ={
      name: "kobe",
      age: 40
    }
    
    func = func.bind(obj)

    func()

  </script>
</body>

</html>